package tech.aistar.corejava.day17.reflection;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:
 * @date 2019/8/6 0006
 */
public class TestPoint {
    public static void main(String[] args) {
        //1. 获取Point的class实例
        try {
            Class<?> c = Class.forName("tech.aistar.corejava.day17.reflection.Point");

            System.out.println(c);//class tech.aistar.corejava.day17.reflection.Point

            System.out.println(c.getName());//tech.aistar.corejava.day17.reflection.Point
            System.out.println(c.getSimpleName());//Point

            //反射创建对象 - 通过java.lang.Class<?>里面的T newsInstance()方法
            Point p = (Point) c.newInstance();//Point p = new Point();

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
    }
}
